package com.example.demo.dao;

import com.example.demo.pojo.ClassificationTable;
import org.apache.ibatis.annotations.Select;

import org.apache.ibatis.annotations.Select;

import org.apache.ibatis.annotations.Mapper;

import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ClassificationTableDao {
    int deleteByPrimaryKey(Integer classificationid);

    int insert(ClassificationTable record);

    int insertSelective(ClassificationTable record);

    ClassificationTable selectByPrimaryKey(Integer classificationid);

    int updateByPrimaryKeySelective(ClassificationTable record);

    int updateByPrimaryKey(ClassificationTable record);

    @Select("select * from classification_table where pid=#{id}")
    List<ClassificationTable> findClassficationtableByPid(int id);


    @Select("SELECT * FROM classification_table  WHERE classification_table.classificationId in (SELECT pId FROM classification_table WHERE classification_table.classificationId IN (SELECT  commodity_list.classificationId FROM commodity_list WHERE goodsId  IN (SELECT goodsid FROM repertorygoods WHERE repertoryId=#{id})))")
    List<ClassificationTable> Classficationtable(int id);

    //根据二级商品分类查找一级商品分类
    @Select("SELECT * FROM classification_table WHERE  classificationId  IN (select pid from classification_table where classificationid=#{id})")
    ClassificationTable findFirstBySecondid(int id);

    //修改一级分类
   @Select("select * from classification_table where pid=0 and classificationId!=#{id} ")
    List<ClassificationTable>findUnlessfirst(int id);

   //修改二级分类
   @Select("SELECT * from classification_table WHERE classificationId!=#{classificationid} AND pId=#{pid}")
    List<ClassificationTable> findUnlessSecond(ClassificationTable classificationTable);


   @Select("SELECT * FROM classification_table where classificationId IN(SELECT classificationId FROM commodity_list WHERE goodsid IN (SELECT goodsId FROM repertorygoods WHERE repertoryId=#{cangku})) and pId=#{pid}")
   List<ClassificationTable> Classficationtable1(ClassificationTable classificationTable);
}